Skip to content

Define the new optional properties "centerToReset" and "centerToZoom" #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

dtrucs
Copy link

@dtrucs dtrucs commented Oct 29, 2024

Thanks for this plugin!
This PR is a small enhancement to explicitly set the view to reset on a center/zoom other than those mounted by the map.

@valentinogagliardi
Copy link
Member

@dtrucs thanks for this PR, I'll ask for a few changes!

* "zoom" and "center" properties are useful when the map is mounted in a particular position
* and you need this button to reset the view to another position.
*/
zoomToReset?: number;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you document these with a comment per property, like title and icon?

* "zoom" and "center" properties are useful when the map is mounted in a particular position
* and you need this button to reset the view to another position.
*/
zoomToReset?: number;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of naming these defaultZoom and defaultCenter?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the start of this contribution, I also thought of these names.
But once I saw the whole thing, I wonder if it wouldn't be ambiguous with the mapContainer's center/zoom definition.

<MapContainer zoom={defaultMapZoom} center={defaultMapCenter}>
  <ResetViewControl
    defaultZoom={defaultZoom}
    defaultCenter={defaultCenter}
  />
</MapContainer>

Maybe the couple targetZoom / targetCenter?
But if you think defaultZoom / defaultCenter is better, i'm totally okay to change it!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any though about this @valentinogagliardi?


describe("ResetViewControl", () => {
const mockHandleViewReset = jest.fn();
let mapInstance = null as Map | null
const defaultMapCenter = [-96.8716348, 32.8205866] as LatLngExpression;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's use new LatLng

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@dtrucs dtrucs force-pushed the Define-centerToReset-and-centerToZoom-properties branch from 88190ca to 8cfb1bc Compare November 7, 2024 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants